package com.company;

import java.io.*;

public class Photo {
    public static void copy(){
        File file = new File("F:\\fengjing.jpg");
        try {
            file.createNewFile();
            FileInputStream fis = new FileInputStream("F:\\360用户文件\\fengjing.jpg");
            DataInputStream dis = new DataInputStream(fis);
            FileOutputStream fos = new FileOutputStream("F:\\fengjing.jpg");
            System.out.println("文件已复制！");
            try (DataOutputStream dos = new DataOutputStream(fos)){
                int temp;
                byte[]buf = new byte[8192];
                while ((temp=dis.read(buf))!=-1){
                    dos.write(buf,0,temp);
                    dos.flush();
                }
                fis.close();
                dos.close();
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        copy();
    }
}
